Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented May 14, 2025

follow up react-component/select#1149

移除 getTriggerDOMNode 后,rc-trigger 中也将移除该方法支持。

Summary by CodeRabbit

  • 新功能

    • 新增了 Placeholder 组件,用于更灵活地渲染占位元素并支持自定义 DOM 引用及回退逻辑。
  • 重构

    • Tour 组件现采用新的 Placeholder 组件替代原有的占位渲染方式,提升了组件结构的清晰度和可维护性。

Copy link

vercel bot commented May 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tour ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2025 9:49am

Copy link

coderabbitai bot commented May 14, 2025

Walkthrough

本次变更新增了一个名为 Placeholder 的 React 组件,并在 Tour.tsx 中用它替换了原有的 Portal + div 占位结构。Placeholder 组件支持通过 ref 暴露 DOM 节点,并可自定义获取容器和回退 DOM 的逻辑,实现了更为集中和灵活的占位符渲染方式。

Changes

文件/分组 变更摘要
src/Placeholder.tsx 新增 Placeholder 组件,支持 ref 暴露、定制容器、回退 DOM 及样式。定义并导出 PlaceholderProps 接口。
src/Tour.tsx 引入并使用 Placeholder 组件,替换原有 Portal + div 结构,移除 getTriggerDOMNode,新增 fallbackDOM 方法。

Sequence Diagram(s)

sequenceDiagram
    participant Parent as 父组件
    participant Tour as Tour 组件
    participant Placeholder as Placeholder 组件
    participant Portal as Portal 组件
    participant DOM as 占位 div

    Parent->>Tour: 渲染 Tour,传递 props
    Tour->>Placeholder: 渲染 Placeholder,传递 open、autoLock、getContainer、domRef、fallbackDOM 等
    Placeholder->>Portal: 渲染 Portal,传递 open、autoLock、getContainer
    Portal->>DOM: 渲染 div(占位元素),附加 domRef、className、style
    Placeholder-->>Parent: 暴露 ref(指向 div 或 fallbackDOM)
Loading

Poem

🐰
新增占位小精灵,
Portal 之上更聪明。
Ref 与样式皆随行,
回退节点自可定。
代码精简又清新,
兔子欢跳庆新生!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/Placeholder.tsx

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

src/Tour.tsx

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected]/node_modules/@umijs/fabric/dist/eslint.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented May 14, 2025

😭 Deploy PR Preview 7faa0e7 failed. Build logs

🤖 By surge-preview

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Tour.tsx (1)

243-260: 组件替换实现优雅,逻辑更集中

使用 Placeholder 组件替换原有的 Portal + div 结构,代码更加清晰和模块化。所有相关的样式、类名和DOM引用逻辑都集中在一处处理,使维护更容易。

注意:代码中的 getContainer={getPopupContainer as any} 使用了类型断言,虽然能正常工作,但可能在未来导致类型安全问题。考虑在 Placeholder 组件的接口定义中进行更精确的类型定义,避免使用 any

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a6f8ca and 7faa0e7.

📒 Files selected for processing (2)
  • src/Placeholder.tsx (1 hunks)
  • src/Tour.tsx (3 hunks)
🔇 Additional comments (3)
src/Placeholder.tsx (1)

1-39: 代码实现清晰且符合组件化设计原则

新增的 Placeholder 组件很好地封装了占位元素的逻辑,使用了 React.forwardRefuseImperativeHandle 优雅地处理了 DOM 引用的暴露和回退机制。这种方式比之前直接使用 Portal + div 的结构更加灵活和可维护。

几点建议:

  1. 考虑为 fallbackDOM 添加默认值,减少使用组件时的必要配置
  2. 可以为 styleclassName 属性也提供默认值,增强组件的易用性
src/Tour.tsx (2)

17-17: 导入新组件符合重构目标

导入 Placeholder 组件为移除 getTriggerDOMNode 使用奠定了基础,这与 PR 的目标一致。


205-207: 有效替代 getTriggerDOMNode 功能

新增的 fallbackDOM 函数很好地替代了原有的 getTriggerDOMNode 逻辑,保持了相同的功能:当目标元素不存在时使用 document.body 作为回退。代码简洁明了。

@zombieJ zombieJ merged commit 1a28b79 into master May 14, 2025
10 checks passed
@zombieJ zombieJ deleted the ref branch May 14, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant